<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>猜数字游戏</title>
</head>
<body>
    <script>
        function getRandom(min,max){
            return Math.floor(Math.random()*(max-min+1))+min;
        }
        var random=getRandom(1,10);
        while(true){
            //死循环
            var num=prompt('你来猜？ 输入1-10之间的一个数字');
            if(num>random){
                alert('你猜大了');
            }
            else if (num<random){
                alert('你猜小了')
            }
            else{
                alert('猜对了');
                break;//结束循环
            }
        }
    </script>
</body>
<ml>
